<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" >
    <script>
        const input = document.querySelector('input');
        input.addEventListener('keyup', function(event){
            console.log(event.key); //获取按下的键
        if(event.key === 'Enter') {
            console.log('按下了回车键');
        }
        })

    </script>
</body>
</html>